package test.io;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.OutputStreamWriter;

public class FileReaderTest01 {
	public static void main(String[] args) {
		FileReader fr = null;
		OutputStreamWriter ow = null;
		try {
			fr = new FileReader("test.txt");
			ow = new OutputStreamWriter(System.out);
			char b[] = new char[255];
			int n = 0;
			while((n = fr.read(b)) != -1){
				ow.write(b, 0 ,n);
				ow.flush();
			}
			
		} catch (FileNotFoundException fe) {
			System.out.println(fe.getMessage());
		} catch (IOException ie) {
			System.out.println(ie.getMessage());
		} finally{
			try {
				
				if(ow != null){
					ow.close();
				}
				if(fr != null){
					fr.close();
				}
				
			} catch (IOException ie) {
				System.out.println(ie.getMessage());
			}
		}
		
	}
}
